<?php


namespace app\api\controller;


use app\api\logic\OrderLogic;
use app\api\logic\UserLogic;
use app\common\controller\BaseApiController;

/**
 * 用户管理
 * Class UserController
 * @package app\api\controller
 */
class UserController extends BaseApiController
{
    /**
     * @var OrderLogic
     */
    private OrderLogic $orderLogic;

    protected function init()
    {
        parent::init();
        $this->logic = new UserLogic();
        $this->orderLogic = new OrderLogic();
    }

    /**
     * 用户信息
     */
    public function info()
    {
        return $this->success($this->logic->getUserInfo(request()->uid));
    }

    /**
     * 浏览记录-最新N条
     */
    public function browserTop()
    {
        return $this->success($this->logic->getBrowser(request()->uid));
    }

    /**
     * 浏览记录分页
     */
    public function browserPage()
    {
        return $this->success($this->logic->getBrowserPage(request()->uid, $this->form));
    }

    /**
     * 浏览记录分页
     */
    public function deleteBrowser()
    {
        return $this->success($this->logic->deleteBrowser(request()->uid, input('goods_id')));
    }

    /**
     * 浏览记录分页
     */
    public function clearBrowser()
    {
        return $this->success($this->logic->clearBrowser(request()->uid));
    }

    /**
     * 订单数量
     */
    public function orderCount()
    {
        return $this->success($this->orderLogic->orderCount(request()->uid));
    }


}